﻿using System;

namespace NetPublisher
{
    static class ExceptionExtensions
    {
        /// <summary>
        /// Get a Message of all exception with inner exceptions
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static string ToStringWithInnerException(this Exception exception)
        {
            var result = exception.Message;
            if (exception.InnerException != null)
                result += " ( " + exception.InnerException.ToStringWithInnerException() + ")";
            return result;
        }
    }
}
